package com.gandong8.derby.core.util;

import cn.hutool.core.bean.BeanUtil;
import org.springframework.util.CollectionUtils;

import java.util.List;


public class CollectCopyUtil {

    public static void copyListProperties(List<?> source, List target, Class<?> targetClass) {
        if (CollectionUtils.isEmpty(source) || target==null) {
            return;
        }
        try {
            for (Object obj : source) {
                Object targetObject = targetClass.newInstance();
                BeanUtil.copyProperties(obj, targetObject);
                target.add(targetObject);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
